<?php
  
  define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8');
  class TyUtils{
      
      
      
     public static function getSmarty(){
          require_once(ROOT_PATH.'plugins/smarty/Smarty.class.php');
          
          $smarty = new Smarty();
          $smarty->cache_dir = ROOT_PATH.'templates/';
          $smarty->compile_dir = ROOT_PATH.'tmp/';
          
          return $smarty;
      }
      
     public static function getFckEditor($elName, $elValue, $size=array('width'=>'100%','height'=>'400')){
        require_once(ROOT_PATH.'plugins/fckeditor/fckeditor.php'); 
        
        $editor = new FCKeditor($elName);
        $editor->BasePath   = '../plugins/fckeditor/';
        
        //$editor->ToolbarSet = 'ttzk_addzk';
        $editor->Width      = $size['width'];
        $editor->Height     = $size['height'];
        $editor->Value      = $elValue;
        
        return $editor->CreateHtml();
     }
     
     function unicodeSubStr($String,$Length,$Append = false) {
        if (strlen($String)<=$Length ) 
        { 
            return $String;
        }else{ 
            $I = 0; 
            while ($I < $Length) 
            { 
                $StringTMP = substr($String,$I,1); 
                if ( ord($StringTMP) >=224 ) 
                { 
                    $StringTMP = substr($String,$I,3); 
                    $I = $I + 3; 
                } 
                elseif( ord($StringTMP) >=192 ) 
                { 
                    $StringTMP = substr($String,$I,2); 
                    $I = $I + 2; 
                } 
                else 
                { 
                    $I = $I + 1; 
                } 
                $StringLast[] = $StringTMP; 
            } 
            $StringLast = implode("",$StringLast); 
            if($Append) 
            { 
                $StringLast .= "..."; 
            } 
            return $StringLast; 
        } 
     }     
         
}
  
  if(!isset($tyUtils)){
      $tyUtils = new TyUtils();
  }
  
?>
